package com.wits.qso.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import net.sf.json.JSONObject;

import com.wits.platform.entity.BaseEntity;

@Entity
@Table(name = "qso_student")
public class Student extends BaseEntity {

	/**
	 * VersionUID
	 */
	private static final long serialVersionUID = 5685838612228086898L;

	/** 学生编号 **/
	private String stuId;

	/** 学生姓名 **/
	private String stuName;

	/** 学生性别 **/
	private String stuSex;

	/** 学生电话 **/
	private String stuTel;

	/** 学生邮箱 **/
	private String stuMail;
	
	/** 登录账号  **/
	private String stuUserId;
	
	/**过期日期**/
	private Date dateExpire;
	
	/** 班级id **/
	private String clsId;

	@Id
	@GenericGenerator(name = "idGen", 
					strategy = "com.wits.platform.common.id.generator.IDGenerator",
					parameters={ 
								@Parameter(name = "segment_value", value = "QSO_STU_ID"), 
								@Parameter(name="table_name",value="wits_id_generator"),
								@Parameter(name="value_column_name",value="gen_value"),
								@Parameter(name="segment_column_name",value="gen_name"),
								@Parameter(name="segment_value_length",value="10"),
								@Parameter(name="sq_format",value="%08d"), 
								@Parameter(name="sq_prefix",value="ST") 
					})
	@GeneratedValue(generator = "idGen")
	@Column(name = "stu_id", nullable = false, insertable = true, updatable = false, length = 10)
	public String getStuId() {
		return stuId;
	}

	public void setStuId(String stuId) {
		this.stuId = stuId;
	}

	@Column(name = "stu_name" , length = 100)
	public String getStuName() {
		return stuName;
	}

	public void setStuName(String stuName) {
		this.stuName = stuName;
	}

	@Column(name = "stu_sex" , length = 2)
	public String getStuSex() {
		return stuSex;
	}

	public void setStuSex(String stuSex) {
		this.stuSex = stuSex;
	}

	@Column(name = "stu_tel" , length = 100)
	public String getStuTel() {
		return stuTel;
	}

	public void setStuTel(String stuTel) {
		this.stuTel = stuTel;
	}

	@Column(name = "stu_mail" , length = 100)
	public String getStuMail() {
		return stuMail;
	}

	public void setStuMail(String stuMail) {
		this.stuMail = stuMail;
	}
	@Column(name = "stu_userid" , length = 50)
	public String getStuUserId() {
		return stuUserId;
	}

	public void setStuUserId(String stuUserId) {
		this.stuUserId = stuUserId;
	}
	
	@Temporal(TemporalType.DATE)
	@Column(name = "date_Expire")	
	public Date getDateExpire() {
		return dateExpire;
	}

	public void setDateExpire(Date dateExpire) {
		this.dateExpire = dateExpire;
	}
	

	@Column(name="cls_id",length=10)
	public String getClsId() {
		return clsId;
	}

	public void setClsId(String clsId) {
		this.clsId = clsId;
	}

	@Override
	public String display() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		return JSONObject.fromObject(this, Student.getBaseJsonConfig())
				.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((stuId == null) ? 0 : stuId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Student other = (Student) obj;
		if (stuId == null) {
			if (other.stuId != null)
				return false;
		} else if (!stuId.equals(other.stuId))
			return false;
		return true;
	}
}
